package org.webArchi.common.utill;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

/**
 * @author amith jayasekara
 *         <p/>
 *         Utility class for  date  and time convertions
 */
public class DateTimeUtil {

    private static final Logger logger = LoggerFactory.getLogger(DateTimeUtil.class);

    /**
     * Get current date in given format
     *
     * @param format expected format
     * @return current date in requested dat format
     */
    public Date getCurrentDate(String format) {
        logger.debug("Attempt to get current date with date format  : {} ", format);

        DateFormat dateFormat = new SimpleDateFormat(format);
        //Getting current date
        java.util.Date date = new java.util.Date();
        dateFormat.format(date);

        return date;
    }
}
